package top.shen33.yang.services.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import top.shen33.yang.model.entity.EdoTag;
import top.shen33.yang.mapper.EdoTagMapper;
import top.shen33.yang.services.EdoTagService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * tag表 服务实现类
 * </p>
 *
 * @author oreilly
 * @since 2018-09-13
 */
@Service
public class EdoTagServiceImpl extends ServiceImpl<EdoTagMapper, EdoTag>implements EdoTagService {

    @Override
    public Class clazz() {
        return EdoTag.class;
    }

    @Override
    @Transactional
    public void doAdd(EdoTag itemEdoTag) {

        itemEdoTag.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doUpdate(EdoTag itemEdoTag) {

        itemEdoTag.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doDelete(String[] ids) {

        QueryWrapper<EdoTag> ew = new QueryWrapper<>();
        ew.in("sid", ids);
        new EdoTag().delete(ew);
    }

    @Override
    public EdoTag getOne(String sid) {

        //关联查询

        EdoTag itemEdoTag = getById(sid);

        return itemEdoTag;
    }

    @Override
    public List<EdoTag> all(EdoTag itemEdoTag) {

        return this.baseMapper.all(itemEdoTag);
    }


        @Override
    public Page<EdoTag> pageInfo(Page page, EdoTag itemEdoTag) {

        List<EdoTag> dataList = this.baseMapper.pageInfo(page, itemEdoTag);
        if(page ==null ){
            page = new Page(0,10000);
        }
        page.setRecords(dataList);
        return page;
    }


    @Override
    @Transactional
    public void doImport(List<EdoTag> dataList) {

        //数据验证

        //保存
        this.saveOrUpdateBatch(dataList);
    }

}
